package Module.WandaView;

import Base.DataFactory;
import Base.TestBase;
import org.testng.Assert;

/**
 * Created by Alain on 2016/3/23.
 */
@SuppressWarnings("unused")
public class View extends TestBase {
    private static TestBase TB = new TestBase();
    private static DataFactory DF = new DataFactory();
    private String requestURL=null, response=null, requestBody=null,
                    projectId           = DF.getCellValue("WandaView", "projectId"),
                    projectVersionId    = DF.getCellValue("WandaView", "projectVersionId"),
                    eTag                = DF.getCellValue("WandaView", "eTag"),
                    sourceId            = DF.getCellValue("WandaView", "sourceId"),
                    floor               = DF.getCellValue("WandaView", "floor"),
                    collisionId         = DF.getCellValue("WandaView", "collisionId");

    /*01.获取项目对应的模型信息
    GET  https://bim.wanda.cn/view/{projectId}/{projectVersionId}/init
    参数名             是否必选    类型      描述          实例值
    projectId	        是	 	             项目ID
    projectVersionId	是	 	             项目版本ID*/
    public String getModelInfo(){
        requestURL = "/view/"+projectId+"/"+projectVersionId+"/init";
        String checkResult[] = {"sourceId", "projectId", "projectVersionId", "etag", "createTime"};

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
            TB.checkResponseValue(checkResult);
        } catch (Exception e) {
            Assert.fail(e.toString());
        }
        return  response;
    }

    /*02.获取模型浏览器专业树
    GET  https://bim.wanda.cn/view/{etag}/{sourceId}/tree
    参数名             是否必选    类型      描述          实例值
    etag	            是	 	             模型ID
    sourceId	        是 	 	             资源ID*/
    public String getModelSourceTree(){
        requestURL = "/view/"+eTag+"/"+sourceId+"/tree";
        String checkResult[] = {"floors", "specialties"};

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
            TB.checkResponseValue(checkResult);
        } catch (Exception e) {}

        return  response;
    }

    /*03.获取构件类型
    GET  https://bim.wanda.cn/view/{etag}/{sourceId}/categories
    参数名             是否必选    类型      描述          实例值
    etag	            是	 	             模型ID
    sourceId	        是 	 	             资源ID*/
    public String getSourceCategories(){
        requestURL = "/view/"+eTag+"/"+sourceId+"/categories";

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e) {}

        return  response;
    }

    /*04.获取碰撞检测的专业树
    GET  https://bim.wanda.cn/view/{etag}/{sourceId}/collision/tree
    参数名             是否必选    类型      描述          实例值
    etag	            是	 	             模型ID
    sourceId	        是 	 	             资源ID*/
    public String getCollisionTree(){
        requestURL = "/view/"+eTag+"/"+sourceId+"/collision/tree";

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e) {}

        return  response;
    }

    /*05.获取指定文件下的构件类型
    GET  https://bim.wanda.cn/view/{etag}/{sourceId}/collision/categories
    参数名             是否必选    类型      描述          实例值
    etag	            是	 	             模型ID
    sourceId	        是 	 	             资源ID*/
    public String getCategoriesWithFile(){
        requestURL = "/view/"+eTag+"/"+sourceId+"/collision/categories";

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e) {}

        return  response;
    }

    /*06.获取碰撞检查设置
    GET  https://bim.wanda.cn/view/{projectId}/{projectVersionId}/{collisionId}/setting
    参数名             是否必选    类型      描述          实例值
    projectId	        是	 	             项目ID
    projectVersionId	是 	 	             项目版本ID
    collisionId	        是 	 	             碰撞ID*/
    public String getCollisionSetting(){
        requestURL = "/view/"+projectId+"/"+projectVersionId+"/"+collisionId+"/setting";

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e) {}

        return  response;
    }

    /*07.获取碰撞检查设置列表
    GET  https://bim.wanda.cn/view/{projectId}/{projectVersionId}/collision/setting/list
    参数名             是否必选    类型      描述          实例值
    projectId	        是	 	             项目ID
    projectVersionId	是 	 	             项目版本ID*/
    public String getCollisionSettingList(){
        requestURL = "/view/"+projectId+"/"+projectVersionId+"/collision/setting/list";

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e) {}

        return  response;
    }

    /*08.设置碰撞检查
    POST  https://bim.wanda.cn/view/{projectId}/{projectVersionId}/collision/setting
    参数名             是否必选    类型      描述          实例值
    */
    public String setCollision(){
        requestURL = "/view/"+projectId+"/"+projectVersionId+"/collision/setting";
        requestBody = null;//-TODO
        //send request
        try {
            response = TB.apiResponse(requestURL, "POST", requestBody);
        } catch (Exception e) {}

        return  response;
    }

    /*09.获取模型对比列表
    GET  https://bim.wanda.cn/view/{projectId}/{projectVersionId}/comparison
    参数名             是否必选    类型      描述          实例值
    projectId	        是	 	             项目ID
    projectVersionId	是 	 	             项目版本ID*/
    public String getModuleComparisonList(){
        requestURL = "/view/"+projectId+"/"+projectVersionId+"/comparison";

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e) {}

        return  response;
    }

    /*10.获取所有构件分类编码
    GET  https://bim.wanda.cn/view/category/code
    参数名             是否必选    类型      描述          实例值*/
    public String getAllCategoryCode(){
        requestURL = "/view/category/code";

        //send request
        try {
            response = TB.apiResponse(requestURL, "GET");
        } catch (Exception e) {}

        return  response;
    }
}
